from flask_script import Manager,Shell
from app import app,db
from app import migrate
from flask_migrate import MigrateCommand
from app.models import User,Post
from config import Config
app.config.from_object(Config)

manager = Manager(app)
manager.add_command('db',MigrateCommand)


##使用上下文解释器来进行方便调试，不用导入很多的模块
@app.shell_context_processor
def make_shell_context():
    return {app:app,'db':db,'User':User,'Post':Post}
manager.add_command("shell", Shell(make_context=make_shell_context))

if __name__ == '__main__':

    manager.run()